package com.gzdh.dishrecognition.ui.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.gzdh.dishrecognition.R;

public class LettersAdapter extends BaseAdapter {
    private final Context mContext;
    private final String[] letters = new String[]{"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K",
            "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"};

    public LettersAdapter(Context context) {
        mContext = context;
    }

    public String[] getLetters() {
        return letters;
    }

    @Override
    public int getCount() {
        return letters.length;
    }

    @Override
    public Object getItem(int position) {
        return letters[position];
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        LettersAdapter.ViewHolder holder;

        if (convertView != null && convertView.getTag() != null) {
            holder = (LettersAdapter.ViewHolder) convertView.getTag();
        } else {
            convertView = View.inflate(mContext, R.layout.menu_fast_add_sort_item, null);
            holder = new LettersAdapter.ViewHolder(convertView);
            convertView.setTag(holder);
        }

        String text = (String) getItem(position);
        holder.text1.setText(text);
        return convertView;
    }

    class ViewHolder {
        TextView text1;

        public ViewHolder(View view) {
            text1 = view.findViewById(R.id.text1);
        }
    }
}
